﻿IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_MediaContentSelectAll]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[cms_sp_MediaContentSelectAll]
GO

create procedure [dbo].[cms_sp_MediaContentSelectAll]
(
@SiteGroupId int,
@SiteId int
)
as
select [MediaContentId] as [Id]
      ,[MediaId]
      ,[SiteId]
      ,[SiteGroupId]
      ,[MetaCode]
      ,[Description]
      ,[CreatedBy]
      ,[DateCreated]
      ,[LastUpdatedBy]
      ,[DateLastUpdated]
      ,[MediaContentName]
      ,[BlockFromSearchEngines]
from dbo.MediaContents
where (MediaContents.SiteGroupId is null and MediaContents.SiteId is null) or 
	(MediaContents.SiteGroupId = @SiteGroupId and MediaContents.SiteId is null) or
	(MediaContents.SiteGroupId = @SiteGroupId and MediaContents.SiteId = @SiteId)



GO


